﻿// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "GameFramework/Actor.h"
#include "AsyncCountdown.generated.h"

/**
 * 
 */
UCLASS()
class MISCELLANEOUSPROJECT_API AAsyncTickActor : public AActor
{
	GENERATED_BODY()
public:
	UPROPERTY(BlueprintReadWrite)
	TArray<int32> CountdownNums;
};

// 定义委托类型
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FCompleteHandleDelegate, int32, Result);

UCLASS()
class MISCELLANEOUSPROJECT_API UMyBPAsyncAction : public UBlueprintAsyncActionBase
{
	GENERATED_BODY()
public:
	UMyBPAsyncAction()
	{
		// // UE_LOG(LogTemp, Warning, TEXT(__FUNCTION__""));
	}

	~UMyBPAsyncAction()
	{
		// // UE_LOG(LogTemp, Warning, TEXT(__FUNCTION__""));
	}

	// 自定义的异步蓝图节点
	UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"), Category = "MyBPAsyncAction")
	static UMyBPAsyncAction* AsyncCountdown(UObject* WorldContextObject, AAsyncTickActor* AsyncTickActor, int32 StartNum);
public:
	//输出节点
	UPROPERTY(BlueprintAssignable)
	FCompleteHandleDelegate OnSucceeded;

	//输出节点
	UPROPERTY(BlueprintAssignable)
	FCompleteHandleDelegate OnFailed;
private:
	FTimerHandle TimerHandle;

protected:
	virtual void Activate() override;
};
